package RemoteServerTest;

import java.rmi.RemoteException;
import java.util.ArrayList;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import Po.Manager;
import Po.Message;
import Po.Result;
import RemoteServer.AdminServer;
import RemoteServerInterface.AdminServerInterface;

public class AdminServerTest {
	AdminServerInterface test;
	@Before
	public void setUp() throws Exception {
		test = new AdminServer();
	}

	@After
	public void tearDown() throws Exception {
	}


	@Test
	public final void testGetManager() throws RemoteException {
		ArrayList<Manager> l = test.getSaleManager();
		Assert.assertTrue(l.size() == 2);
		Assert.assertTrue(l.get(0).name.equals("whk"));
	}
	
	@Test
	public final void testAddGM() throws RemoteException {
		Message m = test.addGeneralManager(new Manager("zzz", "111111"));
		Assert.assertTrue(m.result == Result.Success);
	}
	
	@Test
	public final void testAddSM() throws RemoteException {
		Message m = test.addSaleManager(new Manager("yyy", "222222"));
		Assert.assertTrue(m.result == Result.Success);
	}
	
	@Test
	public final void testModifySM() throws RemoteException {
		Message m = test.modifySaleManager(new Manager("yyy", "11111111"));
		Assert.assertTrue(m.result == Result.Success);
	}
	
	@Test
	public final void testModifyGM() throws RemoteException {
		Message m = test.modifyGeneralManager(new Manager("zzz", "555555"));
		Assert.assertTrue(m.result == Result.Success);
	}
	
	@Test
	public final void testDelSM() throws RemoteException {
		Message m = test.deleteSaleManager(new Manager("yyy", "11111111"));
		Assert.assertTrue(m.result == Result.Success);
	}
	
	@Test
	public final void testDelGM() throws RemoteException {
		Message m = test.deleteGeneralManager(new Manager("zzz", "555555"));
		Assert.assertTrue(m.result == Result.Success);
	}
	
	@Test
	public final void testAdmin() throws RemoteException {
		Message m = test.adminLogin("admin", "admin");
		Assert.assertTrue(m.result == Result.Success);
	}

}
